package com.shengdong.water.code.adapter

import com.shengdong.water.R
import com.shengdong.water.code.base.BaseRecyclerAdapter
import com.shengdong.water.code.bean.Outlet
import com.shengdong.water.code.bean.SignInBean
import com.shengdong.water.code.config.RouterConfig
import com.shengdong.water.code.router.RouterManager
import com.shengdong.water.databinding.ItemVideoMonitorBinding

class VideoMonitorAdapter : BaseRecyclerAdapter<Outlet, ItemVideoMonitorBinding>() {

    override fun getLayoutId() = R.layout.item_video_monitor

    override fun bindData(binding: ItemVideoMonitorBinding, item: Outlet, position: Int) {
        super.bindData(binding, item, position)
        binding.item = item

        binding.tvName.setOnClickListener {
            RouterManager.build(RouterConfig.Management.VIDEO_PLAYER_PATH)
                .withString("videoUrl", item.videoUrl)
                .navigate()
        }
        binding.executePendingBindings()
    }

    // 如果User有唯一ID，可以重写这个方法提高效率
    override fun areItemsTheSame(oldItem: Outlet, newItem: Outlet): Boolean {
        return oldItem.id == newItem.id
    }

    // 内容比较可以更精确
    override fun areContentsTheSame(oldItem: Outlet, newItem: Outlet): Boolean {
        return oldItem.createUser == newItem.createUser && oldItem.id == newItem.id
                && oldItem.name == newItem.name
    }
}